package com.shejimoshi.原型模式;

/**
 * 需要注意的是能够实现克隆的Java类必须实现一个 标识接口 Cloneable，
 * 表示这个Java类支持被复制。如果一个类没有实现这个接口但是调用了clone()方法，
 * Java编译器将抛出一个 CloneNotSupportedException 异常。
 */
public class Mail implements Cloneable{
    private String name;
    private String emailAddress;
    private String content;
    public Mail(){
        System.out.println("Mail Class Constructor");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        System.out.println("clone mail object");
        return super.clone();
    }
}
